Skip to content

Conversation

@dtcxzyw
Copy link
Owner

@dtcxzyw dtcxzyw commented Mar 27, 2025

Link: llvm/llvm-project#133139
Requested by: @dtcxzyw

@github-actions github-actions bot mentioned this pull request Mar 27, 2025
@dtcxzyw
Copy link
Owner Author

dtcxzyw commented Mar 27, 2025

Diff mode

runner: ariselab-64c-v2
baseline: llvm/llvm-project@e5ec87f
patch: llvm/llvm-project#133139
sha256: fed684f411fd8570289c70f9d292e8b97d11c113fd7d3ba7e4f34d9eae3f8a41
commit: addb844

3 files changed, 9 insertions(+), 9 deletions(-)

Improvements:
  instcombine.NumCombined 105509036 -> 105509053 +0.00%
Regressions:
  reassociate.NumChanged 4254618 -> 4254617 -0.00%

1 1 bench/php/optimized/hash_whirlpool.ll
8 8 bench/spike/optimized/sm4ed.ll

@github-actions
Copy link
Contributor

Summary of Changes

This patch modifies LLVM IR files for two cryptographic benchmarks: hash_whirlpool and sm4ed. The primary change involves replacing several xor instructions with or disjoint instructions. Below is a high-level overview of the changes:

  1. Replacement of xor with or disjoint in hash_whirlpool.ll:

    • In the function @WhirlpoolTransform, an xor instruction (%38 = xor i64 %33, %37) is replaced with an or disjoint instruction (%38 = or disjoint i64 %33, %37). This change affects how bits are combined during the Whirlpool hash transformation.
  2. Multiple replacements of xor with or disjoint in sm4ed.ll:

    • Across multiple functions in sm4ed.ll, such as _Z16fast_rv32i_sm4edP11processor_t6insn_tm, _Z16fast_rv64i_sm4edP11processor_t6insn_tm, and others, xor instructions are consistently replaced with or disjoint instructions.
    • For example:
      • %39 = xor i32 %36, %38 becomes %39 = or disjoint i32 %36, %38.
      • %37 = xor i32 %34, %36 becomes %37 = or disjoint i32 %34, %36.
    • These changes occur repeatedly throughout the file, affecting various stages of the SM4 encryption/decryption process.
  3. Consistency of Changes:

    • The replacement of xor with or disjoint is applied uniformly across all relevant functions in both files. This suggests a deliberate optimization or behavioral adjustment aimed at improving performance or correctness.
  4. Impact on Bitwise Operations:

    • The or disjoint instruction ensures that the operands do not overlap, which can lead to more predictable or efficient bitwise operations compared to xor. This might be particularly beneficial in cryptographic algorithms where precise control over bit patterns is crucial.
  5. No Changes to Functionality Beyond Instruction Replacement:

    • No other significant changes (e.g., restructuring of logic, addition/removal of instructions) are observed in the provided diffs. The focus appears to be solely on modifying the type of bitwise operation used.

High-Level Overview

The patch refactors the use of bitwise operations in two cryptographic benchmarks by replacing xor with or disjoint. This change is likely motivated by either performance considerations or stricter adherence to disjointness requirements in certain contexts. The modifications are consistent across multiple functions and files, indicating a systematic update rather than an isolated fix. While the exact rationale for this change is not explicitly stated, it aligns with efforts to optimize or refine the behavior of cryptographic algorithms in LLVM IR.

model: qwen-plus-latest
CompletionUsage(completion_tokens=609, prompt_tokens=2351, total_tokens=2960, completion_tokens_details=None, prompt_tokens_details=None)

@dtcxzyw dtcxzyw closed this Mar 28, 2025
@dtcxzyw dtcxzyw deleted the test-run14111958780 branch May 18, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant